package com.learn.controller.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * swagger相关注解。参考地址https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Annotations
 * · @Schema：类或字段说明。注意该注解内的属性只用于生成文档，不会进行校验，需要校验请使用validation注解
 * ·    name：若不设置该属性则默认为属性名，设置则替代属性名
 * validation注解
 * · @Validated：开启数据检验，在Controller方法参数上使用
 * · @NotBlank：校验String类型不能为空
 * · @NotNull：校验包装类不能为空
 * · @Range：校验数值范围
 */
@Getter
@Setter
public class Swagger3Req {
    @Schema(name = "标题name", description = "标题description", example = "嘿嘿")
    @NotBlank(message = "标题不能为空")
    private String title;
    
    @Schema(description = "描述")
    private String description;
    
    @Schema(description = "电话")
    private String phone;
    
    @Schema(description = "邮箱")
    private String email;
    
    @Schema(description = "日期")
    @NotNull(message = "日期不能为空")
    private Date date;
    
    @Schema(description = "计数", minLength = 0, maxLength = 100)
    @Range(min = 0, max = 100, message = "计数超出范围")
    private Integer count;
}
